home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / print / gs261sr1.zip / GDEVBIT.C < prev    next >
C/C++ Source or Header  |  1993-05-16  |  2KB  |  60 lines

  1. /* Copyright (C) 1991 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gdevbit.c */
  20. /* Fake bitmapped device to estimate rendering time. */
  21. #include "gdevprn.h"
  22.  
  23. /* Define the device parameters. */
  24. #ifndef X_DPI
  25. #  define X_DPI 72
  26. #endif
  27. #ifndef Y_DPI
  28. #  define Y_DPI 72
  29. #endif
  30.  
  31. /* The device descriptor */
  32. private dev_proc_print_page(bit_print_page);
  33. gx_device_printer far_data gs_bit_device =
  34.   prn_device(prn_std_procs, "bit",
  35.     DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
  36.     X_DPI, Y_DPI,
  37.     0,0,0,0,            /* margins */
  38.     1, bit_print_page);
  39.  
  40. /* Send the page to the printer. */
  41. private int
  42. bit_print_page(gx_device_printer *pdev, FILE *prn_stream)
  43. {    /* Just dump the bits on the file. */
  44.     /* If the file is 'nul', don't even do the writes. */
  45.     int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
  46.     int lnum;
  47.     byte *in = (byte *)gs_malloc(line_size, 1, "bit_print_page(in)");
  48.     byte *data;
  49.     int nul = !strcmp(pdev->fname, "nul");
  50.     if ( in == 0 )
  51.         return_error(gs_error_VMerror);
  52.     for ( lnum = 0; lnum < pdev->height; lnum++ )
  53.        {    gdev_prn_get_bits(pdev, lnum, in, &data);
  54.         if ( !nul )
  55.             fwrite(data, 1, line_size, prn_stream);
  56.        }
  57.     gs_free((char *)in, line_size, 1, "bit_print_page(in)");
  58.     return 0;
  59. }
  60.